﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace SignOnline
{
    public partial class FileLoad : System.Web.UI.Page
    {
        public string mFileName = "";
        public string mFilePath = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            mFileName = Request["DocumentID"];
            mFilePath = Server.MapPath("/");
            String method = Request.HttpMethod;
            if (method == "GET")
            {
                if (mFileName == "")
                    return;
                byte[] buffur = null;
                FileStream fs = new FileStream(mFilePath + "\\Documents\\" + mFileName, FileMode.Open, FileAccess.Read);
                try
                {
                    buffur = new byte[fs.Length];
                    fs.Read(buffur, 0, (int)fs.Length);
                   
                }
                catch (Exception)
                {
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
                if (buffur != null)
                {
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Length", buffur.Length.ToString());
                    Response.BinaryWrite(buffur);
                    Response.Flush();
                    Response.End();
                }
            }
        }
    }
}